package com.ios.common.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class DownLoadServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public DownLoadServlet() {
		super();
	}

	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		long fjId = Long.parseLong(request.getParameter("fjId"));
		WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
//		IBizFjService service = (IBizFjService) context.getBean("bizFjServiceImpl");
//		BizFjInfoVO vo = service.findBizFjInfoById(fjId);
		try {
//			if(vo.getBo()!=null)
//			FileDownLoad.getInstance().fileDownLoad(vo.getBo().getFjLj(), response);
		} catch (Exception e) {
			String htmlCode = "<script type=\"text/javascript\" language=\"javascript\">"
					+ "alert('文件下载出错!!!')</script>";
			response.setCharacterEncoding("utf-8");
			response.getWriter().write(htmlCode);
			e.printStackTrace();
		}
	}

	public void init() throws ServletException {
		
	}

}
